﻿namespace SchoolExercise
{
    using System;
    using System.Collections.Generic;

    internal class School
    {
        private List<Class> schoolClasses;

        public School()
        {
            this.schoolClasses = new List<Class>();
        }

        public List<Class> SchoolClasses
        {
            get
            {
                return this.schoolClasses;
            }
        }

        public void AddClass(Class classToAdd)
        {
            bool isNameUnique = true;
            foreach (var classy in this.schoolClasses)
            {
                if (classToAdd.Title == classy.Title)
                {
                    isNameUnique = false;
                    break;
                }
            }

            if (isNameUnique == false)
            {
                throw new ArgumentException("The name of the class must be unique. That one is already used");
            }
            else
            {
                this.schoolClasses.Add(classToAdd);
            }
        }

        public void RemoveClass(Class classToRemove)
        {
            this.schoolClasses.Remove(classToRemove);
        }
    }
}